<html>
<head><meta charset="utf-8"><title>Is changing tuple reprs in const_prop OK? · t-compiler/wg-mir-opt · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/index.html">t-compiler/wg-mir-opt</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html">Is changing tuple reprs in const_prop OK?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="182555409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182555409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182555409">(Dec 04 2019 at 13:34)</a>:</h4>
<p>I'm looking at a few const_prop bugs (<a href="https://github.com/rust-lang/rust/issues/66971" target="_blank" title="https://github.com/rust-lang/rust/issues/66971">#66971</a> and <a href="https://github.com/rust-lang/rust/issues/67019" target="_blank" title="https://github.com/rust-lang/rust/issues/67019">#67019</a>) -- should const_prop be changing representations of tuple values at all? I think the problem may be more general than just values represented as two values (<code>ScalarPair</code>s). Here's an example program:</p>
<div class="codehilite"><pre><span></span>fn test(this: ((u8,),)) {
    assert!((this.0).0 == 0);
}

fn main() {
    test(((0,),));
}
</pre></div>


<p>const_prop changes the argument tuple from</p>
<div class="codehilite"><pre><span></span>        _3 = (const 0u8,);
        _2 = (move _3,);
</pre></div>


<p>to</p>
<div class="codehilite"><pre><span></span>        _3 = const Scalar(0x00) : (u8,);
        _2 = const Scalar(0x00) : ((u8,),);
</pre></div>


<p>While this is probably correct in the sense that <code>((0,),)</code> is represented the same as <code>0</code> in the final assembly, I'm not sure if this is something that <code>const_prop</code> is supposed to be doing. Is this expected? Can anyone comment on this?</p>



<a name="182556616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182556616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182556616">(Dec 04 2019 at 13:49)</a>:</h4>
<p>I think I agree with you. MIR optimizations should try to avoid depending on the layout of types as much as possible IMO.</p>



<a name="182556631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182556631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182556631">(Dec 04 2019 at 13:49)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> Do you have thoughts? ^</p>



<a name="182564051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182564051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182564051">(Dec 04 2019 at 15:09)</a>:</h4>
<p>what do you mean by "depending on the layout of types"?</p>



<a name="182564100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182564100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182564100">(Dec 04 2019 at 15:09)</a>:</h4>
<p>I think using the layout is totally something we should do (same with the optimization shown above where we get trivial constants for tuples and such)</p>



<a name="182564870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182564870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182564870">(Dec 04 2019 at 15:16)</a>:</h4>
<p>Hmm... I guess my feeling was that if you have an <em>n</em>-element tuple, you should always have <em>n</em> operands when assigning to that tuple even if some of the inner types are ZSTs.</p>



<a name="182564927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182564927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182564927">(Dec 04 2019 at 15:16)</a>:</h4>
<p>However, I think the most important thing is consistency with the rest of the MIR pipeline. If everyone is already using layout to do various computations, we should do that as well.</p>



<a name="182565000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182565000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182565000">(Dec 04 2019 at 15:17)</a>:</h4>
<p>oh yea, definitely, iirc <span class="user-mention" data-user-id="119169">@osa1</span> already fixed that in their PR</p>



<a name="182565005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182565005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182565005">(Dec 04 2019 at 15:17)</a>:</h4>
<p>I don't want other passes to have care whether or not ConstProp has run. So the MIR should be just as consistent after ConstProp runs as it is before</p>



<a name="182565039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182565039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182565039">(Dec 04 2019 at 15:17)</a>:</h4>
<p>yes, definitely, the previous code was just broken</p>



<a name="182565043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182565043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182565043">(Dec 04 2019 at 15:18)</a>:</h4>
<p>Agreed</p>



<a name="182565103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182565103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182565103">(Dec 04 2019 at 15:18)</a>:</h4>
<p>cool, all on one boat, I was just misreading</p>



<a name="182565125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182565125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182565125">(Dec 04 2019 at 15:18)</a>:</h4>
<p>No, it's probably my bad. I haven't had <span aria-label="coffee" class="emoji emoji-2615" role="img" title="coffee">:coffee:</span> yet</p>



<a name="182633476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182633476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182633476">(Dec 05 2019 at 07:05)</a>:</h4>
<p>Hmm, so it's fine for const-prop to turns a <code>(0,)</code> to <code>0</code>? I was thinking that that's accidentally done as it changes the logical representation of the variable.</p>



<a name="182653436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182653436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182653436">(Dec 05 2019 at 12:17)</a>:</h4>
<p>Huh, that shouldn't happen, but a Scalar(0) does not mean a 0, it can still be a <code>(0,)</code>.</p>



<a name="182653471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182653471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182653471">(Dec 05 2019 at 12:17)</a>:</h4>
<p>In memory a single elem tuple looks the same as the single elem. The same is true for constants in rustc</p>



<a name="182654244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182654244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182654244">(Dec 05 2019 at 12:28)</a>:</h4>
<p>That does not happen, sorry my example is not quite right (though the question is valid) -- I should've said "turns a ((0, 1),) to a (0, 1)". Agreed that they're represented the same in runtime.</p>



<a name="182655078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182655078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182655078">(Dec 05 2019 at 12:41)</a>:</h4>
<p>Yea, that's wrong</p>



<a name="182655637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182655637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182655637">(Dec 05 2019 at 12:49)</a>:</h4>
<p>Sorry, your answers are a bit too concise for me to understand. Maybe you can respond to my question here <a href="https://github.com/rust-lang/rust/issues/67019" target="_blank" title="https://github.com/rust-lang/rust/issues/67019">https://github.com/rust-lang/rust/issues/67019</a> ?</p>



<a name="182656266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182656266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182656266">(Dec 05 2019 at 12:56)</a>:</h4>
<p>Sorry about that. I'll write up sth more detailed when I get to a PC</p>



<a name="182664530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182664530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182664530">(Dec 05 2019 at 14:38)</a>:</h4>
<p>Thanks</p>



<a name="182745989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182745989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182745989">(Dec 06 2019 at 10:16)</a>:</h4>
<p>I made a writeup on the issue</p>



<a name="182746171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182746171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182746171">(Dec 06 2019 at 10:18)</a>:</h4>
<p>If you want to just fix the ICE for now, you can also just bail out if the tuple doesn't have exactly two fields with <code>Scalar</code> layout</p>



<a name="182746218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182746218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182746218">(Dec 06 2019 at 10:19)</a>:</h4>
<p>this allows the full fix (actually more features, because we'd const prop more) to bake in a separate PR and makes your PR easier to backport in case we need to move it to beta</p>



<a name="182749861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182749861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182749861">(Dec 06 2019 at 11:01)</a>:</h4>
<p>Thanks @oli, that's really helpful. I think I understand the basic idea, I'll give it a try.</p>



<a name="182753089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182753089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182753089">(Dec 06 2019 at 11:55)</a>:</h4>
<p>@oli I'm trying to implement the idea. So far I added two lines to <code>replace_with_const</code>:</p>
<div class="codehilite"><pre><span></span>        let _x = crate::const_eval::op_to_const(&amp;crate::const_eval::mk_eval_cx(self.tcx, DUMMY_SP, self.param_env), value);
        debug!(&quot;op_to_const = {:#?}&quot;, _x);
</pre></div>


<p>but that triggered an assertion in <code>const_eval</code>:</p>
<div class="codehilite"><pre><span></span>thread &#39;rustc&#39; panicked at &#39;assertion failed: `(left == right)`
  left: `8`,
 right: `1`&#39;, src/librustc/mir/interpret/value.rs:319:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:84
   3: &lt;std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display&gt;::fmt
             at src/libstd/sys_common/backtrace.rs:61
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1025
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1428
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:65
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:50
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:193
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:210
  10: &lt;alloc::boxed::Box&lt;F&gt; as core::ops::function::Fn&lt;A&gt;&gt;::call
             at ./src/liballoc/boxed.rs:983
  11: rustc_driver::report_ice
             at src/librustc_driver/lib.rs:1174
  12: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:475
  13: rust_begin_unwind
             at src/libstd/panicking.rs:375
  14: std::panicking::begin_panic_fmt
             at src/libstd/panicking.rs:326
  15: rustc::mir::interpret::value::Scalar&lt;Tag&gt;::check_raw
             at ./&lt;::std::macros::panic macros&gt;:9
  16: rustc::mir::interpret::value::Scalar&lt;Tag&gt;::to_bits
             at ./src/librustc/mir/interpret/value.rs:329
  17: rustc::mir::interpret::value::Scalar&lt;Tag&gt;::to_machine_usize
             at ./src/librustc/mir/interpret/value.rs:409
  18: rustc::mir::interpret::value::ScalarMaybeUndef&lt;Tag&gt;::to_machine_usize
             at ./src/librustc/mir/interpret/value.rs:569
  19: rustc_mir::const_eval::op_to_const
             at src/librustc_mir/const_eval.rs:121
  20: rustc_mir::transform::const_prop::ConstPropagator::replace_with_const
             at src/librustc_mir/transform/const_prop.rs:624
...
</pre></div>


<p>Am I misusing <code>op_to_const</code> or is this something to debug and fix?</p>



<a name="182753420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182753420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182753420">(Dec 06 2019 at 12:01)</a>:</h4>
<p>you should not create a new eval_cx, but reuse the one from the const propagator. You'll have to make <code>op_to_const</code> generic over the machine parameter in order to do this</p>



<a name="182753477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182753477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182753477">(Dec 06 2019 at 12:02)</a>:</h4>
<p>I can't tell if this is the cause of the ICE though, but without that change you'd run into errors later because some allocations don't exist outside the const prop machine</p>



<a name="182753615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182753615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182753615">(Dec 06 2019 at 12:04)</a>:</h4>
<p>OK, I'll try that. <code>1 == 8</code> seems like the LHS is in words but RHS is in bytes so maybe there's a confusion there, but I'm not sure. I'll check.</p>



<a name="182753630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182753630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182753630">(Dec 06 2019 at 12:04)</a>:</h4>
<blockquote>
<p>you should not create a new eval_cx, but reuse the one from the const propagator. You'll have to make <code>op_to_const</code> generic over the machine parameter in order to do this</p>
</blockquote>
<p>There's a typedef I introduced the last time I had to do that which you can probably reuse. <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/const_eval/type.CompileTimeEvalContext.html" target="_blank" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/const_eval/type.CompileTimeEvalContext.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/const_eval/type.CompileTimeEvalContext.html</a></p>



<a name="182753718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182753718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182753718">(Dec 06 2019 at 12:05)</a>:</h4>
<p>Yea the assert failure is a <code>Scalar</code> that is one byte being accessed with a type that is 8. The 8 is correct, since the code uses <code>to_machine_usize</code>, which on a 64bit system looks for an 8 byte value</p>



<a name="182753846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182753846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182753846">(Dec 06 2019 at 12:07)</a>:</h4>
<p>Ok, I found the ICE</p>



<a name="182753855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182753855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182753855">(Dec 06 2019 at 12:07)</a>:</h4>
<p>lol what on earth was I thinking?</p>



<a name="182753863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182753863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182753863">(Dec 06 2019 at 12:07)</a>:</h4>
<p>I think this may be triggerable on stable</p>



<a name="182753919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182753919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182753919">(Dec 06 2019 at 12:08)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/7b482cdf7ce55e05ee8392e1ade70966e3189cfd/src/librustc_mir/const_eval.rs#L108" target="_blank" title="https://github.com/rust-lang/rust/blob/7b482cdf7ce55e05ee8392e1ade70966e3189cfd/src/librustc_mir/const_eval.rs#L108">https://github.com/rust-lang/rust/blob/7b482cdf7ce55e05ee8392e1ade70966e3189cfd/src/librustc_mir/const_eval.rs#L108</a> does not check for slice type and just assumes scalar pairs are slices</p>



<a name="182753920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182753920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182753920">(Dec 06 2019 at 12:08)</a>:</h4>
<p><span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="182754028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182754028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182754028">(Dec 06 2019 at 12:10)</a>:</h4>
<p>ah no. we have checks: <a href="https://github.com/rust-lang/rust/blob/7b482cdf7ce55e05ee8392e1ade70966e3189cfd/src/librustc_mir/const_eval.rs#L67" target="_blank" title="https://github.com/rust-lang/rust/blob/7b482cdf7ce55e05ee8392e1ade70966e3189cfd/src/librustc_mir/const_eval.rs#L67">https://github.com/rust-lang/rust/blob/7b482cdf7ce55e05ee8392e1ade70966e3189cfd/src/librustc_mir/const_eval.rs#L67</a></p>



<a name="182754033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182754033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182754033">(Dec 06 2019 at 12:10)</a>:</h4>
<p>phew</p>



<a name="182754096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182754096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182754096">(Dec 06 2019 at 12:11)</a>:</h4>
<p>But the ICE is still there because <a href="https://github.com/rust-lang/rust/blob/7b482cdf7ce55e05ee8392e1ade70966e3189cfd/src/librustc_mir/const_eval.rs#L80" target="_blank" title="https://github.com/rust-lang/rust/blob/7b482cdf7ce55e05ee8392e1ade70966e3189cfd/src/librustc_mir/const_eval.rs#L80">https://github.com/rust-lang/rust/blob/7b482cdf7ce55e05ee8392e1ade70966e3189cfd/src/librustc_mir/const_eval.rs#L80</a> is wrong in the const prop usage</p>



<a name="182754240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182754240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182754240">(Dec 06 2019 at 12:13)</a>:</h4>
<p>Hmm, right</p>



<a name="182754311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182754311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182754311">(Dec 06 2019 at 12:14)</a>:</h4>
<p>Ok... this is not too fun. I guess you need to split up <code>op_to_const</code> into three parts. </p>
<ol>
<li><a href="https://github.com/rust-lang/rust/blob/7b482cdf7ce55e05ee8392e1ade70966e3189cfd/src/librustc_mir/const_eval.rs#L58-L76" target="_blank" title="https://github.com/rust-lang/rust/blob/7b482cdf7ce55e05ee8392e1ade70966e3189cfd/src/librustc_mir/const_eval.rs#L58-L76">https://github.com/rust-lang/rust/blob/7b482cdf7ce55e05ee8392e1ade70966e3189cfd/src/librustc_mir/const_eval.rs#L58-L76</a></li>
<li><a href="https://github.com/rust-lang/rust/blob/7b482cdf7ce55e05ee8392e1ade70966e3189cfd/src/librustc_mir/const_eval.rs#L77-L86" target="_blank" title="https://github.com/rust-lang/rust/blob/7b482cdf7ce55e05ee8392e1ade70966e3189cfd/src/librustc_mir/const_eval.rs#L77-L86">https://github.com/rust-lang/rust/blob/7b482cdf7ce55e05ee8392e1ade70966e3189cfd/src/librustc_mir/const_eval.rs#L77-L86</a></li>
<li><a href="https://github.com/rust-lang/rust/blob/7b482cdf7ce55e05ee8392e1ade70966e3189cfd/src/librustc_mir/const_eval.rs#L77-L131" target="_blank" title="https://github.com/rust-lang/rust/blob/7b482cdf7ce55e05ee8392e1ade70966e3189cfd/src/librustc_mir/const_eval.rs#L77-L131">https://github.com/rust-lang/rust/blob/7b482cdf7ce55e05ee8392e1ade70966e3189cfd/src/librustc_mir/const_eval.rs#L77-L131</a></li>
</ol>



<a name="182754335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182754335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182754335">(Dec 06 2019 at 12:15)</a>:</h4>
<p>The first and third part is what we can reuse, but the second part we need to change the else-part to actually force allocate the value we got</p>



<a name="182754361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182754361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182754361">(Dec 06 2019 at 12:15)</a>:</h4>
<p>So I'm still trying to find this eval_cx in const-prop. I don't think const-prop has an eval_cx, does it? I can't find it</p>



<a name="182754371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182754371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182754371">(Dec 06 2019 at 12:15)</a>:</h4>
<p>At this point I really suggest you make a small PR just fixing the bug as described earlier, and make the full change in a separate PR, because otherwise we won't be able to tell apart problems from the small fix from problems in the big fix</p>



<a name="182754426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182754426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182754426">(Dec 06 2019 at 12:16)</a>:</h4>
<p>Oh, I think I found it.</p>



<a name="182754432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182754432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182754432">(Dec 06 2019 at 12:16)</a>:</h4>
<p>XD you get it by calling <code>use_ecx</code> :D</p>



<a name="182754445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182754445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182754445">(Dec 06 2019 at 12:16)</a>:</h4>
<p>you can't use it directly</p>



<a name="182754456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182754456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182754456">(Dec 06 2019 at 12:16)</a>:</h4>
<p>(or you shouldn't)</p>



<a name="182754563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182754563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182754563">(Dec 06 2019 at 12:18)</a>:</h4>
<p>Hmm, <code>InterpCx&lt;'mir, 'tcx, ConstPropMachine&gt;</code> is what I have in const-prop, but I really need <code>InterpCx&lt;'mir, 'tcx, CompileTimeInterpreter&lt;'mir, 'tcx&gt;&gt;</code>. Can I use the former for the latter? The Machine arguments are different</p>



<a name="182754616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182754616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182754616">(Dec 06 2019 at 12:20)</a>:</h4>
<blockquote>
<p>At this point I really suggest you make a small PR just fixing the bug as described earlier, and make the full change in a separate PR, because otherwise we won't be able to tell apart problems from the small fix from problems in the big fix</p>
</blockquote>
<p>The bug described earlier is <a href="https://github.com/rust-lang/rust/issues/66971" target="_blank" title="https://github.com/rust-lang/rust/issues/66971">#66971</a> ? Or something else?</p>



<a name="182754650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182754650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182754650">(Dec 06 2019 at 12:20)</a>:</h4>
<p>No, you can't. You need to make <code>op_to_const</code> generic over the machine</p>



<a name="182754671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182754671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182754671">(Dec 06 2019 at 12:20)</a>:</h4>
<blockquote>
<p>If you want to just fix the ICE for now, you can also just bail out if the tuple doesn't have exactly two fields with <code>Scalar</code> layout</p>
</blockquote>
<p>this is the "fix explanation", I can make it more detailed</p>



<a name="182754726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182754726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182754726">(Dec 06 2019 at 12:21)</a>:</h4>
<blockquote>
<p>this is the "fix explanation", I can make it more detailed</p>
</blockquote>
<p>OK, that makes sense though that disables the optimization when type and ABI layout doesn't match... which may be fine I guess.</p>



<a name="182754778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182754778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182754778">(Dec 06 2019 at 12:22)</a>:</h4>
<p>I'll do that and then we can discuss the next steps if that's OK.</p>



<a name="182754780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182754780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182754780">(Dec 06 2019 at 12:22)</a>:</h4>
<p>well, the bug being fixed by checking that it's a two element tuple with each field being <code>Scalar</code> layout is both <a href="https://github.com/rust-lang/rust/issues/66971" target="_blank" title="https://github.com/rust-lang/rust/issues/66971">#66971</a> and <a href="https://github.com/rust-lang/rust/issues/67019" target="_blank" title="https://github.com/rust-lang/rust/issues/67019">#67019</a></p>



<a name="182754810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182754810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182754810">(Dec 06 2019 at 12:22)</a>:</h4>
<p>yea, let's pessimize for now, there's no nice way to resolve this without adding more (and possibly more fragile) code</p>



<a name="182754915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182754915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182754915">(Dec 06 2019 at 12:24)</a>:</h4>
<p>Alright. Just curious about the plan, is this optimization (when type and ABI layout doesn't match) something we want to do in the future or are we shelving it?</p>



<a name="182755165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182755165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182755165">(Dec 06 2019 at 12:27)</a>:</h4>
<p>we want do do it. The type and ABI layout <em>do</em> match, it's just that they are entirely orthogonal ways to think about a type. It is no conflict that the layout of a three element tuple is a <code>ScalarPair</code> if one of the elements is a ZST</p>



<a name="182755230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182755230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182755230">(Dec 06 2019 at 12:28)</a>:</h4>
<p>The bug occurred because we forgot that these things are independent ways to look at values and should not be mixed</p>



<a name="182759578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182759578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182759578">(Dec 06 2019 at 13:23)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> </p>
<blockquote>
<p>bail out if the tuple doesn't have exactly two fields with Scalar layout</p>
</blockquote>
<p>How do I check if the type has two fields with Scalar layout?</p>



<a name="182760136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182760136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182760136">(Dec 06 2019 at 13:30)</a>:</h4>
<p>you check <code>if let Abi::Scalar(_) = ecx.layout_of(field_ty)?.details.abi</code> (inside a <code>use_ecx</code>). You get the field types from the <code>if let ty::Tuple(substs) = ty {</code></p>



<a name="182763543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182763543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182763543">(Dec 06 2019 at 14:11)</a>:</h4>
<p>OK, I have a patch. Starting testing now.</p>



<a name="182765346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182765346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182765346">(Dec 06 2019 at 14:31)</a>:</h4>
<p>Sigh I accidentally cleaned the tree so I'll have to build rustc from scratch now. I'll update the PR in an hour or so.</p>



<a name="182765358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182765358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182765358">(Dec 06 2019 at 14:31)</a>:</h4>
<p>XD oh no</p>



<a name="182765383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182765383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182765383">(Dec 06 2019 at 14:31)</a>:</h4>
<p>But the good news is the test passes. I'll try the other relevant issues now once I have a working build again</p>



<a name="182765471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182765471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182765471">(Dec 06 2019 at 14:32)</a>:</h4>
<p>After this I'd be happy to work on the more general solution to propagating pairs</p>



<a name="182765551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182765551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182765551">(Dec 06 2019 at 14:33)</a>:</h4>
<p>Awesome!</p>



<a name="182765632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182765632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182765632">(Dec 06 2019 at 14:34)</a>:</h4>
<p>I think your changes will fix a crash I'm seeing locally when I try to allow propagation into user variables.</p>



<a name="182767035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182767035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182767035">(Dec 06 2019 at 14:48)</a>:</h4>
<p>PR updated. It fixes 3 issues that I know of.</p>



<a name="182767097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Is%20changing%20tuple%20reprs%20in%20const_prop%20OK%3F/near/182767097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Is.20changing.20tuple.20reprs.20in.20const_prop.20OK.3F.html#182767097">(Dec 06 2019 at 14:49)</a>:</h4>
<p><span aria-label="party ball" class="emoji emoji-1f38a" role="img" title="party ball">:party_ball:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>